<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('添加任务')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-task-add">
        <div class="form-group">
            <label class="col-sm-3 control-label" required>任务标题：</label>
            <div class="col-sm-8">
                <select class="form-control" name="taskTitle" id="taskTitle">
                    <option th:each="taskTitle:${taskTitles}" th:value="${taskTitle.taskTitle}" required>
                        [[${taskTitle.taskTitle}]]
                    </option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">延期至：</label>
            <div class="col-sm-8">
                <input class="form-control" type="datetime-local" name="taskEndTime" id="taskStartTime" step="1">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">申请人：</label>
            <div class="col-sm-8">
                <input type="hidden" id="userId"  name="userId">
                <input  disabled="true" type="text" id="userName" name="userName">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">申请原因：</label>
            <div class="col-sm-8">
                <textarea name="postPoneCause" maxlength="500" class="form-control" rows="3" required></textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">
    var prefix = ctx + "cyq/task/postpone";


    $(function () {
        $("#taskTitle").change(function () {
            var taskTitle = $("#taskTitle").val();
            $("#userName").empty();
            $.get(
                "/cyq/task/postpone/selectUserNameByTaskTitle",
                {
                    taskTitle: taskTitle,
                },
                function (data) {
                    console.log(data)
                    $("#userId").val(data.userId)
                    $("#userName").val(data.userName);
                }, "json"
            )
        })
    })

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-task-add').serialize());
        }
    }
</script>
</body>
</html>
